unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, RzPanel, RzButton, RzGroupBar, StdCtrls, RzLstBox;

type
  TForm1 = class(TForm)
    RzToolbar2: TRzToolbar;
    RzToolbar1: TRzToolbar;
    RzToolButton1: TRzToolButton;
    RzToolButton2: TRzToolButton;
    RzToolButton3: TRzToolButton;
    RzToolButton4: TRzToolButton;
    RzToolButton5: TRzToolButton;
    RzToolButton6: TRzToolButton;
    Button1: TButton;
    RzListBox1: TRzListBox;
    RzListBox2: TRzListBox;
    RzListBox3: TRzListBox;
    Button2: TButton;
    Button3: TButton;
    procedure FormShow(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure RzListBox2DragOver(Sender, Source: TObject; X, Y: Integer;
      State: TDragState; var Accept: Boolean);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure RzToolButton6Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormShow(Sender: TObject);
var
  I:Integer;
begin
  RzToolbar1.TextOptions:=ttoSelectiveTextOnRight;
  RzToolbar2.TextOptions:=ttoSelectiveTextOnRight;



  RzListBox1.Items.Clear;

  for I:=0 to RzToolbar1.ControlCount-1 do
  begin
    RzListBox1.AddObject(RzToolbar1.Controls[I].Name,nil);
    //RzToolbar1.Controls[I].Visible:=False;
  end;

  for I:=0 to RzToolbar2.ControlCount-1 do
  begin
    RzListBox1.AddObject(RzToolbar2.Controls[I].Name,nil);
    //RzToolbar2.Controls[I].Visible:=False;
  end;


end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  {RzToolButton1.Parent:=RzToolbar2;
  RzToolButton1.Align:=alLeft;}
  if RzListBox1.SelectedItem='' then Exit;  
  RzListBox2.Items.Add(RzListBox1.SelectedItem);
  RzListBox1.Delete(RzListBox1.ItemIndex);
end;

procedure TForm1.RzListBox2DragOver(Sender, Source: TObject; X, Y: Integer;
  State: TDragState; var Accept: Boolean);
begin
  if Source is TRzListBox then
  begin
    Accept:=True;
  end;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  if RzListBox1.SelectedItem='' then Exit;
  RzListBox3.Items.Add(RzListBox1.SelectedItem);
  RzListBox1.Delete(RzListBox1.ItemIndex);
end;

procedure TForm1.Button3Click(Sender: TObject);
var
  I:Integer;
  Btnx:TRzToolbarButton;
  StrsA:TStringList;
begin
  StrsA:=TStringList.Create;

  for I:= RzToolbar1.ControlCount-1   downto 0 do
  begin
    StrsA.AddObject('',RzToolbar1.Controls[I]);
    RzToolbar1.RemoveFreeNotification(RzToolbar1.Controls[I]);
  end;

  //RzToolbar1.RemoveFreeNotification();

  for I:= RzToolbar2.ControlCount-1   downto 0 do
  begin
    StrsA.AddObject('',RzToolbar2.Controls[I]);
    RzToolbar2.RemoveFreeNotification(RzToolbar2.Controls[I]);    
  end;

  for I:=0 to StrsA.Count-1 do
  begin
    Btnx:=nil;
    Btnx:=TRzToolbarButton(StrsA.Objects[I]);
    if Btnx=nil then Continue;

    if RzListBox2.Items.IndexOf(Btnx.Name)<>-1 then
    begin
      Btnx.Parent:=RzToolbar1;
    end else
    if RzListBox3.Items.IndexOf(Btnx.Name)<>-1 then
    begin
      Btnx.Parent:=RzToolbar2;
    end;
    Btnx.Align:=alLeft;
    Btnx.Left:=0;
    Btnx.Visible:=True;
  end;


  Btnx:=TRzToolbarButton.Create(RzToolbar1);
  Btnx.Width:=60;
  Btnx.Caption:='True';
  Btnx.Parent:=RzToolbar1;

  RzToolbar1.Repaint;
  RzToolbar2.Repaint;
  RzToolbar1.Invalidate;
  RzToolbar2.Invalidate;
  RzToolbar1.AutoResize:=True;



     

end;

procedure TForm1.RzToolButton6Click(Sender: TObject);
begin
  ShowMessage('RzToolButton6:my name is b3');
end;

end.
